package com.example.service

import com.example.vo.Hospital
import org.springframework.stereotype.Service

@Service
class XmlServiceImpl implements XmlService {

	@Override
	public void createXmlHospitals(String xml) {

				
	}

	@Override
	public List<Hospital> readXmlHospitalList() {
		
		def parser = new XmlParser()
		
		def doc =  parser.parse("d://groovyTest/hospital.xml");
		
		List<Hospital> rList = new ArrayList<>();
		def iter = doc.iterator();
		while(iter.hasNext()) {
			def e = iter.next();
			Hospital h = new Hospital();
			h.setHospitalId(e.hospitalId.text());
			h.setHospitalName(e.hospitalName.text())
			h.setTimerTime(e.timerTime.text());
			h.setDbServerName(e.dbServerName.text())
			h.setDbName(e.dbName.text())
			h.setToEmail(e.toEmail.text())
			rList.add(h);
		}
		
		return rList;
	}
}
